// pages/myhistorydata/myhistorydata.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    src: '',
    identityId: 0,
    schoolId: 0,
    userId: 0
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    console.log(options)
    if (options.type == 'wechatmyhistory') {
      this.setData({
        identityId: parseInt(options.identityId),
        schoolId: parseInt(options.schoolId),
        userId: parseInt(options.userId),
        src: options.src + '?schoolId=' + parseInt(options.schoolId) + '&userId=' + parseInt(options.userId) + '&identityId=' + parseInt(options.identityId)
      })
    } else if (options.type == 'electricalsafety') {
      // console.log(options.deviceName)
      this.setData({
        // schoolId: parseInt(options.schoolId),
        // src: `${options.src}?schoolId=${parseInt(options.schoolId)}&deviceName=${options.deviceName}&deviceId=355488020030634`
        src: `${options.src}?departmentId=${options.departmentId}`
      })
    } else if (options.type == 'accessDevice') {
      let deviceUrl ;
      switch (options.deviceType){
        case 'smoke': deviceUrl = 'wechatsmokedevice';break;
        case 'upanddown': deviceUrl = 'wechatupanddowndevice'; break;
        // case 'visit': deviceUrl = 'wechatsmokedevice'; break;
        // case 'facerecord': deviceUrl = 'wechatsmokedevice'; break;
      }
      this.setData({
        // schoolId: parseInt(options.schoolId),
        // src: `${options.src}?schoolId=${parseInt(options.schoolId)}&deviceName=${options.deviceName}&deviceId=355488020030634`
        src: `${options.src}/${deviceUrl}?departmentId=${options.departmentId}`
      })
    } else if (options.type == 'securityRank') {
      let rankUrl ;
      rankUrl = 'wechatsecurityrank';
      this.setData({
        src: `${options.src}/${rankUrl}?departmentId=${options.departmentId}`
      })
    } 
    console.log(this.data.src)
  // console.log(options.deviceName)
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {
    
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})